<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta name="keywords"
    content="HTML,CSS,HTML5,CSS3,ES6,JavaScript,Vue,Vue.js,TS,TypeScript,webpack,node.js,git,npm,前端,全栈,Web开发" />
  <meta name="description" content="一位Web开发工程师的学习、工作笔记-星之痕。
    内容涵盖：HTML,CSS,HTML5,CSS3,ES6,JavaScript,Vue,Vue.js,TS,TypeScript,前端,全栈,Web开发……等" />
  <title>Vue.js 笔记-星之痕</title>
  <link rel="stylesheet" href="./css/global.css">
</head>

<body>
  <div id="app">

    <div>
      <h2>{{title}}</h2>
      <ul>
        <li v-for='msg in messages'>{{msg}}</li>
      </ul>
    </div>
    <button v-on:click='action'>点击</button>

  </div>

  <script src="js/vue.js"></script>
  <script src="node_modules/axios/dist/axios.min.js"></script>
  <script>

    console.log(axios);
    Vue.config.productionTip = false; //阻止vue页面在启动时的生产提示

    const app = new Vue({
      el: '#app',
      data: {
        title: 'this is a title',
        messages: [
          'this is a vue demo!',
        ],
        keyword: '2'
      },
      computed: {

      },
      methods: {
        action() {
          this.title = 'hello!';
          // 发起一个post请求
          axios({
            method: 'post',
            url: '/user/12345',
            data: {
              firstName: 'Fred',
              lastName: 'Flintstone'
            }
          });

          // 发起一个 GET 请求 (默认请求方式)
          axios('/api/user/12345');

          // 在 node.js 用GET请求获取远程图片
          // axios({
          //   method: 'get',
          //   url: 'https://ts1.cn.mm.bing.net/th/id/R-C.725f6e9ab200ef0171103b4ccaacc131?rik=JJ8uPW9h0eF%2f5A&riu=http%3a%2f%2f5.1015600.com%2f2015%2fpic%2f000%2f369%2f725f6e9ab200ef0171103b4ccaacc131.jpg&ehk=mh3DUIoARBayHZycroSZ%2bpqJZtvRsdOeqCF1gZsHglE%3d&risl=&pid=ImgRaw&r=0',
          //   responseType: 'stream'
          // }).then(function (response) {
          //   response.data.pipe(fs.createWriteStream('ada_lovelace.jpg'))
          // });

        }
      }
    });

    // Vue实例上的$methods,以及Prototype上$methods 是Vue内部封装好的，可供开发人员调用的方法
    console.log(app);
  </script>
</body>

</html>
